package org.zch;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动类
 * <a href="http://localhost:9099/swagger-ui/index.htm">...</a>
 *
 * @author
 */
@SpringBootApplication
@ServletComponentScan
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    /**
     * 启动时打印文档api地址
     *
     */
    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {
            System.out.print("\n------------------------->>>>>");
            // 获取当前IP
            InetAddress localHost = InetAddress.getLocalHost();
            String localIP = localHost.getHostAddress();
            System.out.print("文档api地址： http://" + localIP + ":9999/doc.html");
            System.out.println("<<<<<-------------------------\n");
        };
    }


}
